<template>
	<view class="news">
		<news-item @itemClick="goDetail" :list = "newsList" ></news-item>
		<!-- <view class="news_item" v-for="item in newsList" :key="item.id">
			<image :src="item.img_url"></image>
			<view class="right">
				<view class="title">{{item.title}}</view>
				<view class="info">
					<text>发表时间：{{item.add_time}}</text>
					<view><text>浏览次数：{{item.click}}</text></view>
				</view>
			</view>
		</view> -->
	</view>
</template>

<script>
	import newsItem from '../../components/news-item/news-item.vue'
	export default {
		data() {
			return {
				newsList:[]
			}
		},
		methods: {
		async getNews(){
			const res = await this.$myrequest({
				url:'/api/getnewslist',
				})
				this.newsList = res.data.message
			},
			goDetail(id){
				console.log(id)
				uni.navigateTo({
					url:'/pages/news-detail/news-detail?id='+id
				})
			}
		},
		components:{"news-item":newsItem},
		onLoad() {
			this.getNews()
		}
	}
</script>

<style lang="scss">
	.news {
	// 	.news_item{
	// 		display: flex;
	// 		padding: 10rpx 20rpx;
	// 		border-bottom: 1px solid $shop-color;
	// 		image{
	// 			min-width: 200rpx;
	// 			max-width: 200rpx;
	// 			height: 150rpx;
	// 		}
	// 		.right{
	// 			margin-left: 15rpx;
	// 			display: flex;
	// 			flex-direction: column;
	// 			justify-content: space-between;
	// 			.title{
	// 				font-size: 30rpx;
	// 			}
	// 			.info{
	// 				font-size: 25rpx;
	// 				text:nth-child(2){
	// 					margin-left: 30rpx;
	// 				}
	// 			}
	// 		}
	// }
}
</style>
